package com.lecture.java8.stack;

public class MainTest {

    public static void main(String[] args) {
        // 创建示例树
        DeviceTree root = new DeviceTree("Root", null);
        DeviceTree child1 = new DeviceTree("Child1", root);
        DeviceTree child2 = new DeviceTree("Child2", root);
        DeviceTree grandchild1 = new DeviceTree("Grandchild1", child1);
        DeviceTree grandchild2 = new DeviceTree("Grandchild2", child1);

        // 构建树结构
        root.addChild(child1);
        root.addChild(child2);
        child1.addChild(grandchild1);
        child1.addChild(grandchild2);

        // 更新 count
        root.updateCount();

        // 输出结果
        System.out.println("Root Count: " + root.getCount()); // 应为5（root + child1 + child2 + grandchild1 + grandchild2）
        System.out.println("Child1 Count: " + child1.getCount()); // 应为3（child1 + grandchild1 + grandchild2）
    }
}
